﻿// <copyright file="ChartSeriesScaleTest.cs" company="Oleg V. Polikarpotchkin">
// Copyright © 2008-2009 Oleg V. Polikarpotchkin. All Right Reserved
// </copyright>
// <author>Oleg V. Polikarpotchkin</author>
// <email>ov-p@yandex.ru</email>
// <date>2009-01-23</date>
// <summary>WPF OpenWPFChart library. ChartSeriesScaleTest class Test.</summary>
// <revision>$Id$</revision>

using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenWPFChart.Parts;

namespace Tests
{
    /// <summary>
    ///This is a test class for ChartSeriesScaleTest and is intended
    ///to contain all ChartSeriesScaleTest Unit Tests
    ///</summary>
	[TestClass()]
	public class ChartSeriesScaleTest
	{
		#region TestContext
		private TestContext testContextInstance;
		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}
		#endregion TestContext

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion

		/// <summary>
		/// A test for parametrizied constructor
		///</summary>
		[TestMethod()]
		public void ConstructorTest()
		{
			List<object> series = new List<object>()
			{
				"first",
				"second",
				"third",
				"fourth",
				"fifth",
				"sixth",
				"seventh",
				"eighth",
				"ninth",
				"tenth",
			};
			ChartSeriesScale target = new ChartSeriesScale(series, series[0], series[series.Count - 1], 300);

			double actual = target.ToPixels(series[0]);
			Assert.AreEqual(0.0, actual);

			actual = target.ToPixels(series[series.Count - 1]);
			Assert.AreEqual(300.0, actual);
		}

		/// <summary>
		///A test for Ticks
		///</summary>
		[TestMethod()]
		public void TicksTest()
		{
			List<string> series = new List<string>()
			{
				"first",
				"second",
				"third",
				"fourth",
				"fifth",
				"sixth",
				"seventh",
				"eighth",
				"ninth",
				"tenth",
			};
			ChartSeriesScale target = new ChartSeriesScale()
			{
				Series = series,
				Start = series[0],
				Stop = series[series.Count - 1],
				LongTickRate = 5
			};
			List<ScaleTick> expected = new List<ScaleTick>()
			{
				new ScaleTick("first", true),
				new ScaleTick("second", false),
				new ScaleTick("third", false),
				new ScaleTick("fourth", false),
				new ScaleTick("fifth", false),
				new ScaleTick("sixth", true),
				new ScaleTick("seventh", false),
				new ScaleTick("eighth", false),
				new ScaleTick("ninth", false),
				new ScaleTick("tenth", false)
			};
			List<ScaleTick> actual = target.Ticks().ToList();
			CollectionAssert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for ToPixels
		///</summary>
		[TestMethod()]
		public void ToPixelsTest()
		{
			List<string> series = new List<string>()
			{
				"first",
				"second",
				"third",
				"fourth",
				"fifth",
				"sixth",
				"seventh",
				"eighth",
				"ninth",
				"tenth",
			};
			ChartSeriesScale target = new ChartSeriesScale()
			{
				Series = series,
				Start = series[0],
				Stop = series[series.Count - 1]
			};
			List<ScaleTick> expected = new List<ScaleTick>()
			{
				new ScaleTick("first", false),
				new ScaleTick("second", false),
				new ScaleTick("third", false),
				new ScaleTick("fourth", false),
				new ScaleTick("fifth", false),
				new ScaleTick("sixth", false),
				new ScaleTick("seventh", false),
				new ScaleTick("eighth", false),
				new ScaleTick("ninth", false),
				new ScaleTick("tenth", false)
			};
			double actual = target.ToPixels(series[0]);
			Assert.AreEqual(0.0, actual);
		}

		/// <summary>
		///A test for FromPixels
		///</summary>
		[TestMethod()]
		public void FromPixelsTest()
		{
			List<string> series = new List<string>()
			{
				"first",
				"second",
				"third",
				"fourth",
				"fifth",
				"sixth",
				"seventh",
				"eighth",
				"ninth",
				"tenth",
			};
			ChartSeriesScale target = new ChartSeriesScale()
			{
				Series = series,
				Start = series[0],
				Stop = series[series.Count - 1]
			};
			List<ScaleTick> expected = new List<ScaleTick>()
			{
				new ScaleTick("first", false),
				new ScaleTick("second", false),
				new ScaleTick("third", false),
				new ScaleTick("fourth", false),
				new ScaleTick("fifth", false),
				new ScaleTick("sixth", false),
				new ScaleTick("seventh", false),
				new ScaleTick("eighth", false),
				new ScaleTick("ninth", false),
				new ScaleTick("tenth", false)
			};
			object actual = target.FromPixels(0.0);
			Assert.AreEqual(series[0], actual);
		}
	}
}
